<template>
    <el-select-v2 
        ref="selectRef"
        class="bar"
        v-model="modelValue[itemValue]"
        filterable
        placeholder="Select"
        clearable
        highlight-current-row
        :options="options"
        @change="updateOptions"
        >
    </el-select-v2>
</template>

<script lang="ts" setup name="SingleSelect">
    import { onMounted, ref, watch } from 'vue';

    let options:any = ref([])
    let initAllOptions: any = ref([])
    const itemValue = ref('') // 选项名
    const props = defineProps(['modelValue', 'searchItem', 'updateOptions',])

    
    onMounted(() => {
        itemValue.value = props.searchItem.value
    })

    watch(props.searchItem, (newValue:any) => {
        initAllOptions.value = newValue.options
        options.value = newValue.options
    }, {deep: true})

</script>